package com.act.moudles.user.entity;

import java.util.Date;

import com.act.utils.validations.AddGroup;
import com.act.utils.validations.UpdateGroup;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.Data;
import lombok.NonNull;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;


/**
 * 密钥(SecretKey)表实体类
 *
 * @author makejava
 * @since 2023-05-18 11:09:01
 */
@Data
@TableName("s_secret_key")
public class SecretKey {
    //主键
    @NotNull(message = "主键不能空！",groups = UpdateGroup.class)
    private Long keyId;
    //密钥名称
    @NotEmpty(message = "密钥名称不能为空",groups = {UpdateGroup.class, AddGroup.class})
    private String keyName;
    //密钥值
    @NotEmpty(message = "密钥名称不能为空",groups = {UpdateGroup.class, AddGroup.class})
    private String keyValue;
    //多租户ID
    private String tenantId;
    //过期时间
    private Date outTime;
    //创建时间
    private Date createTime;
    //备注
    private String remark;
    //创建人用户ID
    private Long createUserId;

    @TableField(exist = false)
    private String createUserName;


    public LambdaQueryWrapper<SecretKey> query(){
        LambdaQueryWrapper<SecretKey> query = new LambdaQueryWrapper<>();
        query.eq(keyId != null,SecretKey::getKeyId,keyId);
        query.like(StringUtils.isNotEmpty(keyName),SecretKey::getKeyName,keyName);
        query.eq(StringUtils.isNotEmpty(tenantId),SecretKey::getTenantId,tenantId);
        return query;
    }


    }

